package com.ocean.array;

import java.util.Arrays;

/**
 * https://leetcode.cn/problems/move-zeroes/
 */
public class MoveZeroes {

    public static void main(String[] args) {
        int[] height = new int[]{0};
//        int[] height = new int[]{0, 1, 0, 3, 12};
        new MoveZeroes().moveZeroes(height);
    }

    public void moveZeroes(int[] nums) {
        int s = 0;
        int f = 1;
        while (f < nums.length) {
            if (nums[s] != 0) {
                s++;
            } else {
                if (nums[f] != 0) {
                    nums[s] = nums[f];
                    nums[f] = 0;
                    s++;
                }
            }
            f++;
        }

        System.out.println(Arrays.toString(nums));
    }
}
